package com.cal.utms.action.maintenance;

import com.cal.utms.dao.maintenance.CustomerDaoImpl;
import com.cal.utms.dto.maintenance.CustomerDto;
import com.cal.utms.model.maintenance.CustomerModel;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class CustomerAction extends ActionSupport implements ModelDriven<CustomerDto> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	protected CustomerDaoImpl customerDao = new CustomerDaoImpl();
	private CustomerDto customerBean = new CustomerDto();
	private String emails;
	private String bankAccounts;
	private String jointApplicans;
	private String contactPersons;
	private int customerId;
	private boolean success;
	CustomerModel customerModel = new CustomerModel();

	public String getAllCustomer() {
		customerBean.setSuccess(true);
		customerBean.setCustomerBeans(customerModel.createCustomerBeanList(customerDao.getCustomerList()));
		return Action.SUCCESS;
	}

	public String saveCustomer() {
		customerBean.setSuccess(true);
		customerModel.saveCustomer(customerBean, emails, bankAccounts, jointApplicans, contactPersons);
		return Action.SUCCESS;
	}

	public String updateCustomer() {
		customerBean.setSuccess(true);
		customerBean.setId(customerId);
		customerModel.updateCustomer(customerBean, emails, bankAccounts, jointApplicans, contactPersons);
		return Action.SUCCESS;
	}

	@Override
	public CustomerDto getModel() {
		return customerBean;
	}

	public CustomerDto getCustomerBean() {
		return customerBean;
	}

	public void setCustomerBean(CustomerDto customerBean) {
		this.customerBean = customerBean;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getEmails() {
		return emails;
	}

	public void setEmails(String emails) {
		this.emails = emails;
	}

	public String getBankAccounts() {
		return bankAccounts;
	}

	public void setBankAccounts(String bankAccounts) {
		this.bankAccounts = bankAccounts;
	}

	public String getJointApplicans() {
		return jointApplicans;
	}

	public void setJointApplicans(String jointApplicans) {
		this.jointApplicans = jointApplicans;
	}

	public String getContactPersons() {
		return contactPersons;
	}

	public void setContactPersons(String contactPersons) {
		this.contactPersons = contactPersons;
	}

	public int getCustomerId() {
		return customerId;
	}

	public void setCustomerId(int customer_id) {
		this.customerId = customer_id;
	}

}
